﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LTJ.Common;
using LTJ.FrameWork;
using LTJ.Entity;

namespace uswinweb.datacontrol
{
    public partial class basetypeList : System.Web.UI.UserControl
    {
        public DataTable basetypeTab = new DataTable();
        public string strWhere = " 1=1 ";
        public int pagesize = 10;
        public int pageindex = SASRequest.GetInt("currentPage", 1);
        public string action = SASRequest.GetString("action");
        public string parpms = SASRequest.GetString("parms").Trim();
        public string pageList = "";
        public string orderstr = "";
        public string _str = "";
        public basetypeList()
        {
            if (action == "del")
            {
                int msg = BaseTypes.DelBaseType(parpms);
                if (msg == -1)
                {
                    _str = "<script language='javascript' defer>alert('此类别下有基础数据，请先删除基础数据。');</script>";
                }
            }
            if (action == "search")
            {
                strWhere += " and tname like '%" + parpms + "%'";
            }
            if (action == "sort")
            {
                orderstr = parpms;
            }
            int recordcount = 0;
            recordcount = BaseTypes.GetBaseTypeCount(strWhere);
            basetypeTab = BaseTypes.GetBaseTypesByPage(pageindex, pagesize, strWhere, orderstr);
            pageList = GetPageList(recordcount, pagesize, pageindex);
            
        }
        public string GetPageList(int recordcount, int pagesize, int currentpage)
        {
            if (SASRequest.GetInt("postnumber", 0) > 0)
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "basetypeList.ascx", "postnumber=" + SASRequest.GetInt("postnumber", 0), "showdata");
            }
            else
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "basetypeList.ascx", "action=" + action + "&parms=" + parpms + "", "showdata");
            }
        }
    }
}